home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / database / foxsqz.zip / DEMO.PRG next >
Text File  |  1994-03-14  |  8KB  |  285 lines

  1. ************************************************************************
  2. ** Demo program for Foxsqz.PLB/.FLL                                       *
  3. ** (c) 1993-94 Master Creative Software, Inc.                           *
  4. ** Please feel free to use any or all of this code in your app           *
  5. ************************************************************************
  6. * Last Updated 2/16/94 6:22pm WSM Added more Comments and Formating Code
  7.  
  8.  
  9.  
  10. Set Echo off
  11. Clear
  12. Set Talk off
  13.  
  14. _ExitBtn  = 0                                                    && Button status
  15.  
  16. SqzPage   =  .T.                                                && Page Listing
  17. SqzArc    =  Padr("FOXSQZ.SQZ",20," ")                            && Archive File Name
  18. SqzPass   =  Space(15)                                            && Password for Encryption
  19. SqzFSpec  =  "*.*"+Space(17)                                    && Files to Act on
  20. SqzXClude =  Space(15)                                            && Files to Exclude
  21. SqzINCFile=  Space(15)                                            && Include File Name
  22. SqzFnct   =  1                                                    && Function to Perform
  23. SqzCmpTyp =  1                                                    && Compression Method
  24. SqzOver   =  .F.                                                && OverWrite Existing files when decompressing
  25. SqzDst    =  Space(15)                                            && destination for Decompression
  26. SqzRestDT =  .F.                                                && restore Orginal Date time of File
  27. SqzQuiet  =  .F.                                                && Operate quietly
  28. SqzSpan   =  .F.                                                && Span Disks
  29. SqzWipe   =  .F.                                                && Wipe disk used for spanning
  30. SqzFmtTyp =  1                                                    && Format MEthod
  31. SqzLowDens=  .F.                                                && LowDensity Disks Used
  32. SqzVerify =  .F.                                                && DOS Verfy Flag
  33. SqzTDrv   =  "  "                                                && Temp Drive
  34. SqzIncSub =  .F.                                                && Include Subdirectories
  35. SqzStoPath=  .F.                                                && Store PathNames
  36. SqzResTree=  .F.                                                && Restore Directory Tree
  37. SqzStorSpec= .F.
  38. SqzLowMem  = .F.
  39.  
  40. * Intialize Error Strings Foxsqz returnes offset-1 into this array
  41. * so you need to add one when indexing the array, this is because
  42. * foxpro arrays start at offset 1 and Foxsqz returns 0 for success..
  43.  
  44. Dime FoxSqzErr[50]
  45.  
  46. FoxSqzErr[1] = "No Errors Were Detected"
  47. FoxSqzErr[2] = "Invalid or Bad Input File "
  48. FoxSqzErr[3] = "Invalid or Bad Output File"
  49. FoxSqzErr[4] = "Invalid or Bad Global Header in SQZ file"
  50. FoxSqzErr[5] = "Error Writing Global Header"
  51. FoxSqzErr[6] = "Invalid or Bad Local Header"
  52. FoxSqzErr[7] = "Error Writing Local Header"
  53. FoxSqzErr[8] = "Error allocating Local Memory"
  54. FoxSqzErr[9] = "Error Allocating Foxpro memory"
  55. FoxSqzErr[10] = "File Read Error Type 1"
  56. FoxSqzErr[11] = "File Read Error Type 2"
  57. FoxSqzErr[12] = "File Read Error Type 3"
  58. FoxSqzErr[13] = "DosFile Size Error"
  59. FoxSqzErr[14] = "File Write Error Type 1"
  60. FoxSqzErr[15] = "File Write Error Type 2"
  61. FoxSqzErr[16] = "File Write Error Type 3"
  62. FoxSqzErr[17] = "Error In Parameter 1 (Options String)"
  63. FoxSqzErr[18] = "Error In Parameter 2 (SQZ file Name)"
  64. FoxSqzErr[19] = "Error In Parameter 3 (File Specifiers)"
  65. FoxSqzErr[20] = "Error Opening Input"
  66. FoxSqzErr[21] = "Error Opening OutPut"
  67. FoxSqzErr[22] = "No Parameters Passed "
  68. FoxSqzErr[23] = "Error Opening WorkFile"
  69. FoxSqzErr[24] = "File Write Error"
  70. FoxSqzErr[25] = "Create Aborted By User"
  71. FoxSqzErr[26] = "Error Allocating Transfer Memory"
  72. FoxSqzErr[27] = "Error InValid/Unknown Parameter"
  73. FoxSqzErr[28] = "UnKnown compression type"
  74. FoxSqzErr[29] = "Error in Password"
  75. FoxSqzErr[30] = "InValid PassWord"
  76. FoxSqzErr[31] = "Not a FOXSQZ Archive or Incompatible version"
  77. FoxSqzErr[32] = "Error in specified destination drv/path"
  78. FoxSqzErr[33] = "Unable to select target    drive/path"
  79. FoxSqzErr[34] = "Could not Open Include File"
  80. FoxSqzErr[35] = "Invalid Inclusion argument"
  81. FoxSqzErr[36] = "Invalid Exclusion argument"
  82. FoxSqzErr[37] = "Max Exclusions is 5"
  83. FoxSqzErr[38] = "I needed disk #1 to Start"
  84. FoxSqzErr[39] = "User aborted"
  85. FoxSqzErr[40] = "No Spanning support for this function"
  86. FoxSqzErr[41] = "Unable to Format Disk"
  87. FoxSqzErr[42] = "Nothing to do "
  88. FoxSqzErr[43] = "Exceeded max files allowed in demo"
  89. FoxSqzErr[44] = "Disk is Not Removable, will not format"
  90. FoxSqzErr[45] =  "No More Internal FoxSqz Memory Handles"
  91. FoxSqzErr[46] =  "Invalid Drive"
  92.  
  93. Do while .T.
  94.     Clear
  95.     SqzFSpec  =  "*.*"+Space(17)    
  96.     do sqz.spx
  97.     if Lastkey()=27 OR _ExitBtn=1
  98.         Exit
  99.     Endif
  100.     Set Libr to Foxsqz
  101.  
  102.     ** Build FoxSqz Arguments ***
  103.  
  104.     *Get Main FoxSqz Funtion  Squeeze , UnSqueeze, Delete, List , etc *
  105.  
  106.     Fnct = iif(SqzFnct = 1,"S",iif(SqzFnct = 2,"U",iif(SqzFnct=3,"L","D")))
  107.     Arg1 = Fnct                                                    && Add To Argument One List
  108.  
  109.     *Now Create Arguments that affect all Foxsqz Function
  110.  
  111.     if !Empty(SqzPass)                                            && Is Password Encryption Requested ?
  112.         Arg1 = Arg1 + "E("+allTrim(SqzPass)+")"
  113.     Endif
  114.  
  115.     if SqzQuiet
  116.         Arg1 = Arg1 + "Q"
  117.     Endif 
  118.  
  119.     if SqzLowMem 
  120.         Arg1 = Arg1 + "$"
  121.     Endif
  122.  
  123.     if SqzVerify                                                && Need Dos Verify Flag Set ?
  124.         Arg1 = Arg1 + "V"
  125.     Endif
  126.  
  127.     if !Empty(SqzTDrv)                                            && Want to Redirect Foxsqz Tmp Files ?
  128.         Arg1 = Arg1 + "G("+Trim(SqzTDrv)+")"
  129.     Endif
  130.  
  131.     if !Empty(SqzXClude)                                        && Was there any files to Exclude
  132.         Ex1 = ""
  133.         l = len(Trim(SqzXClude))
  134.         for i = 1 to l
  135.             tmp = Substr(SqzXClude,i,1)
  136.             if tmp = " "
  137.                 if !Empty(Ex1)
  138.                     Arg1 = Arg1 + "X("+Ex1+")"
  139.                     Ex1 = ""
  140.                 else
  141.                     *ignore leading trailing space
  142.                 Endif
  143.             else
  144.                 Ex1 = Ex1 + tmp
  145.             Endif
  146.         EndFor
  147.         if !Empty(Ex1)                                            && Get Last Arg
  148.             Arg1 = Arg1 + "X("+Ex1+")"
  149.         Endif
  150.     Endif
  151.  
  152.     * Now Proccess Squeeze Modifiers
  153.     if Fnct = "S"                                                && Compression Modifiers
  154.  
  155.         ** compression Type Fast Maximum or None
  156.         Arg1 = Arg1 + iif(SqzCmpTyp=1,"M",iif(SqzCmpTyp=2,"F","N"))
  157.  
  158.         ** Use a Include File ?
  159.         if !Empty(SqzINCFile)
  160.             Arg1 = Arg1 + "@("+allTrim(SqzINCFile)+")"
  161.         Endif
  162.  
  163.         ** Recurse into Subdirectories ?
  164.         if SqzIncSub
  165.             Arg1 = Arg1 + "R"
  166.         Endif
  167.  
  168.         **Store Paths Recursed Into ?
  169.         if SqzIncSub AND SqzStoPath
  170.             Arg1 = Arg1 + "P"
  171.  
  172.             ** What about paths specified
  173.             if SqzStorSpec
  174.                 Arg1 = Arg1 + "*"
  175.             Endif
  176.         Endif
  177.  
  178.         ** Span Multiple Floppies
  179.         if SqzSpan
  180.             Arg1 = Arg1 + "&"
  181.         Endif
  182.  
  183.         ** Format the Target if Removable ?
  184.         if SqzWipe
  185.             Arg1 = Arg1 + "W("
  186.  
  187.             ** How do we eant to Format it QUICK , Conditionaly or Unconditionaly
  188.             do case
  189.             case SqzFmtTyp = 1
  190.                 Arg1 = Arg1 + "q"
  191.             case SqzFmtTyp = 2
  192.                 Arg1 = Arg1 + "c"
  193.             case SqzFmtTyp = 3
  194.                 Arg1 = Arg1 + "u"
  195.             EndCase
  196.  
  197.             ** format Low Density disks ?
  198.             if SqzLowDens
  199.                 Arg1 = Arg1 + "l"
  200.             Endif
  201.  
  202.             ** Close Wipe Modifiers
  203.             Arg1 = Arg1 + ")"
  204.         Endif
  205.  
  206.     Endif
  207.  
  208.     ** Process UnSqueeze Function
  209.  
  210.     if Fnct="U"
  211.  
  212.         * Overwrite Existing Files ?
  213.         if SqzOver
  214.             Arg1 = Arg1 + "O"
  215.         Endif
  216.  
  217.         ** Restore Original File Date and Time ?
  218.         if SqzRestDT
  219.             Arg1 = Arg1 + "R"
  220.         Endif
  221.  
  222.         ** Restore to Driver/Directory other than Default ?
  223.         if !Empty(SqzDst)
  224.             if Right(AllTrim(SqzDst),1)!="\"
  225.                 SqzDst = Padr(AllTrim(SqzDst)+"\",15," ")
  226.             Endif
  227.             Arg1 = Arg1 + "T("+allTrim(SqzDst)+")"
  228.         Endif
  229.  
  230.         ** Restore Directory Tree ?
  231.         if SqzResTree
  232.             Arg1 = Arg1 + "P"
  233.         Endif
  234.  
  235.     Endif
  236.  
  237.     ** Proccess List Option
  238.     if Fnct="L" AND SqzPage                                        && Page the Display "More Like"
  239.         Arg1 = Arg1 + "P"
  240.     Endif
  241.  
  242.     * Make FOXSQZ part of Foxpro
  243.     Set Libr to Foxsqz
  244.  
  245.  
  246.     Define Window SQZ from 2,-1 to 22,80
  247.     @1,3 Say ' Will Execute -> =FoxSqz("'+ Arg1 + '","'+allTrim(SqzArc) +'","' + allTrim(SqzFSpec)+'")'
  248.     Activate Window SQZ
  249.     if Empty(SqzFSpec)
  250.         SRet = FoxSqz(Arg1,allTrim(SqzArc))
  251.     Else
  252.         SRet = FoxSqz(Arg1,allTrim(SqzArc),allTrim(SqzFSpec))
  253.     Endif
  254.  
  255.     Set Libr to
  256.  
  257.     Clear TypeAhead
  258.     Wait "FOXSQZ Return = ["+Ltrim(Str(SRet))+"] - "+SqzError(SRet) Window NoWait
  259.  
  260.     if SRet=0 AND Fnct = "L"
  261.         Wait "Strike Any Key " Window
  262.     Endif
  263.  
  264.     Release Window SQZ
  265. Enddo
  266.  
  267. Define Window PRNWIND from 0,0 to 23,79 TITLE ;
  268. " [ FOXSQZ Documentation ]"  PANEL COLOR w/n,n/w,w/n
  269. modi file FOXSQZ.DOC NOMOD WINDOW PRNWIND
  270. Release Window PRNWIND
  271.  
  272. Return
  273.  
  274.  
  275.  
  276. *******************************************
  277. Procedure SqzError
  278. *******************************************
  279. Param _Er
  280.  
  281. return FoxSqzErr[_er+1]
  282.  
  283.  
  284.  
  285.